2026-02-01T01:40:09Z
Q: How can I tell if my terminal supports TrueColor (24-bit color)?
A: You can run the following command to test if your terminal supports TrueColor:
awk 'BEGIN{
s="/\\/\\/\\/\\/";
for (colnum = 0; colnum<77; colnum++) {
r = 255-(colnum*255/76);
g = (colnum*510/76);
b = (colnum*255/76);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,(colnum%4)+1,1);
}
printf "\n";
}'The above script is from:
If your terminal hardware supports TrueColor, you should see a smooth gradient of colors from red to green to blue. If you see a limited number of colors or a blocky gradient, your terminal may not support true color.
You can also check the COLORTERM environment variable by typing:
echo $COLORTERM
truecolorIf the output is “truecolor” or “24bit”, your terminal hardware supports TrueColor. For most situations, this is sufficient to confirm TrueColor support, and further checks are not generally not beneficial or necessary.
Even if your terminal hardware supports TrueColor, your terminfo may not. Keep in mind that the number of colors set in terminfo only affects applications that choose to use it. A terminfo setting of 256 colors does not limit which of the 16M colors an NCurses application can display, but only the number of color pairs that can be displayed simultaneously.
Note: The remainder of this section takes a deep dive into a rabbit hole that most users will not benefit from exploring. If your terminal hardware supports TrueColor, and the COLORTERM variable indicates TrueColor support, you needn’t continue reading.
You can check your terminfo color capabilities by typing:
tput colorsIf the output is 16777216, your terminfo supports TrueColor.
Even if your hardware supports TrueColor, but the above indicators report only 256 colors or less, you can set the TERM variable to a value that supports Truecolor. For example, you can set the TERM variable to “xterm-direct” by adding the following line to your ~/.bashrc or ~/.zshrc file:
export TERM=xterm-directThe caveat is that xterm-direct and other terminfo files may come with limitations. For example, I have found that xterm-direct, lacks the “ccc” (Can-Change-Color) flag. This flag is advisory only for applications that choose to use it.
I use one of::
export TERM=xterm-ghostty
export TERM=xterm-kitty
export TERM=xterm-bwYou can create your own custom terminfo entry using infocmp and tic, but beware. Terminfo is a complex and sometimes arcane system, and not all applications will work properly with custom entries.
Both the Ghostty and Kitty terminfo files set Number of Colors to 256, and that is perfectly understandable considering that:
If you are determined to have more than 256 colors at one time, you can get around this issue by using infocmp to create a custom terminfo entry that specifies higher color capabilities. Here is an example of how to do this, but it is not recommended.
infocmp xterm-256color > xterm-myterm.tiAdd or modify the following lines in xterm-myterm.ti
ccc, colors#0x1000000, pairs#0x10000Once you have finished editing xterm-myterm.ti, compile it using tic:
tic xterm-myterm.tiAnd, set your TERM environment variable to your new terminfo entry:
export TERM=xterm-mytermYou can also refer to this helpful list of terminals and their color support:
Q: I am trying to view a program file in view, but it is displaying ANSI escape codes.
A: No worries. I ran into the same problem. View is not recognizing the ANSI escape codes. Taking a closer look at the file, I can see the “intro” characters repeated, “0x1b[0x1b[”. This happens when the output file of a colorizer or highlighter is processed a second time by a colorizer or highlighter. It tries to put ANSI escape codes around the existing ANSI escape codes, resulting in the “0x1b[0x1b[” sequence, which View can’t interpret.
Out of curiosity, I ran the same file through less, which produced the same results as C-Menu View. In the world of pagers, less is the gold-standard, and apparently they chose not to address this issue. Therefore, it seems the best solution is to avoid double exposure. If you have a file that has been colorized or highlighted, don’t run it through another colorizer or highlighter. Use C-Menu’s stripansi to remove the ANSI escape codes before re-colorizing or re-highlighting. This works for C-Menu View as well as less.
Below, I have included a screenshot using less.